import { request, requestUpload, $request } from '../../utils/request';
import { getLiveId } from '../../utils/storage';

// 获取发送礼物排行榜
export function getGiftRankList() {
  return request('hmGiftController/findGiftRankList6', 'GET', {
    splid: getLiveId(),
  });
}
// 获取男女方发送礼物排行榜
export function getRoleGiftRankList() {
  return request('hmGiftController/findGiftRankList7', 'GET', {
    splid: getLiveId(),
  });
}
// 发送礼物
export function sendGift(paramObj) {
  return request('hmGiftController/sendGift6', 'POST', {
    splid: getLiveId(),
    giftconst: paramObj.giftId,
  });
}
// 发送霸气弹幕礼物
export function sendDanmuGift(paramObj) {
  return request('hmGiftController/sendGift6', 'POST', {
    splid: getLiveId(),
    giftconst: paramObj.giftId,
    content: paramObj.giftWish,
    gift_source: paramObj.giftSource,
  });
}

// 发送礼物广播
export function sendGiftBroadCast(paramObj) {
  return request('sendMsgController/liwuGo6', 'POST', {
    splid: getLiveId(),
    liwuId: paramObj.giftId,
    content: paramObj.content || '',
  });
}

// 打赏歌手（调起支付前置下单接口）
export function tipSinger({ openid, giftId, singerId, contentJson, USER_ID }) {
  return request('hmWxmoney/tipSinger', 'POST', {
    splid: getLiveId(),
    openid,
    giftId,
    singerId,
    contentJson,
    USER_ID,
  });
}
// 支付
export function diamondRecharge(paramObj) {
  return request('hmWxmoney/chongzhiMiao', 'POST', {
    total: paramObj.total,
    userId: paramObj.userId,
    openid: paramObj.openId,
  });
}

// 领取vip头像框
export function becomeVip() {
  return request('wxScan/becomeVip', 'POST', {
    miao_vip: 'vip1',
    splid: getLiveId(),
  });
}

// 选择图片
export function wxChooseImage() {
  return new Promise((resolve, reject) => {
    // 打印wxChooseImage
    console.log("wxChooseImage");
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: res => {
        resolve(res);
      },
      fail: err => {
        reject(err);
      },
    });
  });
}

// 上传图片
export function uploadHeadImg(path) {
  return requestUpload('beiJing/shangchuanTomcat', path);
}

// 修改个人信息
export function editUserInfo(paramObj) {
  return request('hmGiftController/editUserInfo', 'POST', {
    wx_name: paramObj.wx_name,
    avator: paramObj.avator,
    table_number: paramObj.table_number,
    position: paramObj.position,
    type: paramObj.type,
    splid: getLiveId(),
  });
}

export function buyLivePhoto(livePhotoId) {
  return request('hmGiftController/buyPhoto', 'POST', {
    id: livePhotoId,
    splid: getLiveId(),
  });
}

// 提现记录
export function getWithdrawDetail() {
  return request('hmGiftController/myHbyInfoList2', 'POST', {});
}

// 提现
export function withDrawHbyMoney() {
  return $request('payment/hbyTx', 'POST', {});
}

// 红包明细
export function getHbDetail() {
    return request('hmGiftController/myHbyInfoList1', 'POST', {});
}


// 全场红包雨
export function reqSendAllHby({
  totalfee,
  openid,
  data1,
  data2,
  data3,
  USER_ID,
}) {
  return request('hmWxmoney/userRedBao', 'POST', {
    splid: getLiveId(),
    totalfee,
    openid,
    data1,
    data2,
    data3,
    USER_ID
  })
}

// 点歌接口 
export function reqOrderSong(paramObj) {
  return request('hmWxmoney/sendMusicGift', 'POST', {
    id: paramObj.songId,
    userId: paramObj.userId,
    openid: paramObj.openid,
    photo_end_url: paramObj.orderSongFormJson,
    splid: getLiveId(),
  });
}